package ch.kerbtier.malurus.coreimpl;

import java.io.Serializable;

import ch.kerbtier.malurus.MalurusInstance;
import ch.kerbtier.malurus.Visitor;
import ch.kerbtier.malurus.Component;

public class CiMalurusInstance implements MalurusInstance, Serializable{
	private CiComponent root;

	public CiMalurusInstance() {
	}

	public void setRoot(Component root) {

		if (this.root != null) {
			this.root.setId(null);
			this.root.setInstance(null);
		}

		this.root = (CiComponent) root;
		this.root.setId("root");
		this.root.setInstance(this);
	}
	
	public Visitor visit(Visitor visitor){
		if(this.root != null){
			this.root.acceptVisitor(visitor);
		}
		return visitor;
	}

	public CiComponent getRoot() {
		return root;
	}
}
